var ws, aid;
document.addEventListener('plusready',function(){
	ws = plus.webview.currentWebview();
	aid = ws.aid;//病例（订单）Id
	var dat = plus.storage.getItem('orderlist');
	var data = $.parseJSON(dat);
	$.each(data, function(k,v) {
		if(v.id == aid){
			plus.nativeUI.closeWaiting();
//			console.log(JSON.stringify(v));
			var str ='';
			switch(v.status){
				case '0':str = '待付款';break;
				case '1':str = '待接单';break;
				case '2':str = '待收货';break;
				case '3':str = '已完成';break;
			}
			$('.line-h-44').text(str);
			$('.name').text(v.binfo.name);
			$('.sex').text(v.binfo.sex);
			if(v.binfo.age != 0 && v.binfo.age)$('.age').text(v.binfo.age);
			$('.marry').text(v.binfo.marry);
			$('.weight').text(v.binfo.weight);
			$('.height').text(v.binfo.height);
			$('.nation').text(v.binfo.nation);
			$('.phone').text(v.binfo.phone);
			$('.address').text(v.binfo.address);
			if(v.newly == 1){
				$('.newly').text('复诊');
			}
			$('.ztime').text(v.ztime);
			$('.history').text(v.history);
			//处方
			if(v.recipe){
				var recipe = v.recipe.split(';');
				var str = '';
				$.each(recipe, function(key,value) {
					if(value == ''){
						return true;
					}
					var rec = value.split(',');
					console.log(rec);
					str += '<li>'+
								'<span>'+rec[0]+'</span><span class="mui-pull-right mui-h5">'+rec[1]+'</span>'+
							'</li>';
				});
				str += '<li>'+
							'<span>合计：</span><span>'+v.total+'元</span>'+
						'</li>';
				$('.recipe').html(str);
			}else{//如为拍照上传的病例，且暂未后台添加数据
				console.log(v.camera);
				var list = '';
				$.each(v.camera, function(key, value) {
					console.log(value)
					list += '<img src="'+webRoot + value+'" data-preview-src="" data-preview-group="1"/>';
				});
				$('.recipe').html(list);
			}
			
			//服药注意事项
			v.time?$('.time').text(v.time):$('.time').text('无...');
			v.num?$('.num').text(v.num):$('.num').text('无...');
			v.eatnotice?$('.eatnotice').text(v.eatnotice):$('.eatnotice').text('无...');
			v.runnotice?$('.runnotice').text(v.runnotice):$('.runnotice').text('无...');
		}
	})
},false)